package com.say.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBOpenHelper extends SQLiteOpenHelper {

	public DBOpenHelper(Context context) {
		super(context, "say2.db", null, 3);
	}

	/*
函数public void onCreate(SQLiteDatabase db)
是在调用getReadableDatabase()或者是getWritableDatabase()第一次创建数据库的时候执行,
实际上是在第一次得到SQLiteDatabse对象的时候，才会调用这个方法.
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE person(personid integer primary key autoincrement, name varchar(20), phone VARCHAR(12) NULL, amount integer)");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("ALTER TABLE person ADD amount integer");
	}

}
